added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / CSASPNETUserControlEventExpose / ReadMe.txt
blob6a16d1e171622f26de41a656d996ffd5b5335415
1 =============================================================================
2               CSASPNETuserControlEventsExpose Overview
3 =============================================================================
5 /////////////////////////////////////////////////////////////////////////////
6 Summary:
8 The project illustrates how to bubble an event from Web User Control to the 
9 web page that may display something on Web Page according to which event is 
10 fired in this User control.
13 /////////////////////////////////////////////////////////////////////////////
14 Demo
16 Click the CSASPNETuserControlEventsExpose.sln directly and open the 
17 CSASPNETuserControlEventsExpose website to test the page directly.
19 If you want to have a further test, please follow the demonstration steps 
20 below.
22 Step 1: View the Default.aspx,you will find some Controls,select the 
23 dropdownlist value.
25 Step 2: When click the the button control whose value is 'I am inside User 
26 Control',
28 The webpage custom event will fire, display the dropdownlist selected value 
29 and inform user the usercontrol's button click is clicked.
32 /////////////////////////////////////////////////////////////////////////////
33 Code Logical:
35 Step 1. Declare a delagate and a event in the user control code behind,
36 add one button to this User Control.
38 Step 2. Add the following lines of code in the click event of button of 
39 usercontrol.
41     if (MyEvent != null)
42     {
43         this.MyEvent(sender, e);
44     }
45     Response.Write("User Control¡¯s Button Click <BR/>");
47 Step 3. In the Default.aspx.cs file,Load the usercontrol, and subscribe the 
48 event of the user control in the page load event.
50 Step 4. Define a suitable event handler to display the dropdownlist selected 
51 value.
54 /////////////////////////////////////////////////////////////////////////////
55 References:
57 MSDN: Events and Delegates
58 http://msdn.microsoft.com/en-us/library/17sde2xt(VS.71).aspx
60 FAQs for Web Forms
61 http://forums.asp.net/t/1360420.aspx
63 Catch event from Web User Control in Webpage
64 http://devcandy.blogspot.com/2008/06/catch-event-from-web-user-control-in.html
67 /////////////////////////////////////////////////////////////////////////////